import os
import pandas as pd
import re


def read_excel():
    dtype_dict = {'date': 'str'}
    df = pd.read_excel('2404计费日志核实.xlsx', sheet_name='Sheet1', skiprows=0, dtype=dtype_dict)
    print(df.count())

    dict = {}
    for row in df.itertuples(index=True, name="jfRecord"):
        bb = dict.get(row.apiCode)
        if bb:
            bb['appNames'].add(row.appName)
            bb['countSum'] += row.count
        else:
            dict[row.apiCode] = {'appNames': {row.appName}, 'appNum': 0, 'countSum': row.count}

    for k, v in dict.items():
        v['appNum'] = len(v['appNames'])
        print(k, ','.join(list(v['appNames'])), v['appNum'], v['countSum'])


read_excel()